package com.birdboot.test;


import java.util.Arrays;

public class SplitDemo {
    public static void main(String[] args) {
        String line = "1=2=3=4=5===6=7===8======";
        String [] data1 = line.split("=");
        System.out.println(Arrays.toString(data1));//[1, 2, 3, 4, 5, , , 6, 7, , , 8]


        String [] data2 = line.split("=",2);//限制拆两项
        System.out.println(Arrays.toString(data2));//[1, 2=3=4=5===6=7===8======]


        String [] data3 = line.split("=",4);//限制拆四项
        System.out.println(Arrays.toString(data3));//[1, 2, 3, 4=5===6=7===8======]


        String [] data4 = line.split("=",1000);//限制大于能拆出来的项数
        System.out.println(Arrays.toString(data4));//[1, 2, 3, 4, 5, , , 6, 7, , , 8, , , , , , ]


        String [] data5 = line.split("=",0);//0 和默认不写一样
        System.out.println(Arrays.toString(data5));//[1, 2, 3, 4, 5, , , 6, 7, , , 8]


        String [] data6 = line.split("=",-1);//当limit<0时，应拆尽拆
        System.out.println(Arrays.toString(data6));//[1, 2, 3, 4, 5, , , 6, 7, , , 8, , , , , , ]
    }


}
